The structure of my DOORS objects is as follows |
Re: Concatenate Object Heading (Level 1) and object text (Level 3)
Perhaps start with this:
int L1 = level(obj)
string Display = ""
if (L1 == 3)
{ oName = parent(parent(obj))
Display = oName."Object Heading"
if (!null Display) Display = Display ": "
}
displayRich(Display (obj."Object Text")
|
Re: Concatenate Object Heading (Level 1) and object text (Level 3) |
Re: Concatenate Object Heading (Level 1) and object text (Level 3) llandale - Thu Jan 14 14:18:36 EST 2010
Perhaps start with this:
int L1 = level(obj)
string Display = ""
if (L1 == 3)
{ oName = parent(parent(obj))
Display = oName."Object Heading"
if (!null Display) Display = Display ": "
}
displayRich(Display (obj."Object Text")
Paul Miller |
Re: Concatenate Object Heading (Level 1) and object text (Level 3) SystemAdmin - Thu Jan 14 17:50:27 EST 2010 Paul Miller {code}// Find (grand-)parent object at given level /* Find the respective (grand-)parent object at a specified level in the object hierarchy USAGE Object getParentObj(Object obj, int iLevel) iLevel > 0: absolute value specifying the (grand-)parent object's level iLevel < 0: relative value of (grand-)parent object's level in relation to the input object's level iLevel = 0: return input object */ pragma runLim, 0 Object getParentObj(Object obj, int iLevel) { // Find (grand-)parent object at given level Object pObj = null int iObjLevel int i if (!null obj) { // Object is not null iObjLevel = level obj if (iLevel == 0){pObj = obj} else { // Specified level is not 0 if (iLevel > 0) { // Object level specified as absolute value // Calculate respective relative level iLevel = iLevel - iObjLevel } // Object level specified as absolute value if (iLevel < 0) { // Check for absolute level values below input object level pObj = obj for i in 1: -1 * iLevel do { // Move upwards through object hierarchy pObj = parent pObj if (null pObj){break} } // Move upwards through object hierarchy } // Check for absolute level values below input object level } // Specified level is not 0 } // Object is not null return pObj } // Find (grand-)parent object at given level } Peter |
Re: Concatenate Object Heading (Level 1) and object text (Level 3) Peter_Albert - Fri Jan 15 04:16:48 EST 2010
Now hopefully properly formatted (the preview button seems to have disappeared)
// Find (grand-)parent object at given level
/*
Find the respective (grand-)parent object at a specified level in the
object hierarchy
USAGE
Object getParentObj(Object obj, int iLevel)
iLevel > 0: absolute value specifying the (grand-)parent object's level
iLevel < 0: relative value of (grand-)parent object's level in relation
to the input object's level
iLevel = 0: return input object
*/
pragma runLim, 0
Object getParentObj(Object obj, int iLevel)
{ // Find (grand-)parent object at given level
Object pObj = null
int iObjLevel
int i
if (!null obj)
{ // Object is not null
iObjLevel = level obj
if (iLevel == 0){pObj = obj}
else
{ // Specified level is not 0
if (iLevel > 0)
{ // Object level specified as absolute value
// Calculate respective relative level
iLevel = iLevel - iObjLevel
} // Object level specified as absolute value
if (iLevel < 0)
{ // Check for absolute level values below input object level
pObj = obj
for i in 1: -1 * iLevel do
{ // Move upwards through object hierarchy
pObj = parent pObj
if (null pObj){break}
} // Move upwards through object hierarchy
} // Check for absolute level values below input object level
} // Specified level is not 0
} // Object is not null
return pObj
} // Find (grand-)parent object at given level
|
Re: Concatenate Object Heading (Level 1) and object text (Level 3) SystemAdmin - Thu Jan 14 17:50:27 EST 2010 Paul Miller I think you are saying that a particular 'root parent' object can have applicable descendents at various levels. I would use a 'while' statement, but if you REALLY MUST use recursion, perhaps due FSC, Fancy-Code-Syndrom, it may look like this:
bool IsParentRootObject(Object obj)
{ // Is this object a parent root object?
if (null obj) return(false)
// You must right this code yourself.
return(True or False)
} // end IsParentRootObject()
Object GetParentRootObject(Object oChild)
{ // Find the parent root object for this child object
// ** Recursion Enabled **
// A parent root object has no parent, parent-root-object
if (null oChild) return(null)
if (IsParentRootObject(oChild)) return(null)
Object oParent = parent(oChild)
if (null oParent) //-
then return(null)
elseif (IsParentRootObject(oParent)) //-
then return(oParent)
else return(GetParentRootObject(oParent)) // ** Recursion Here **
} // end GetParentRootObject()
|